package com.kun.dynamic.core;

import org.springframework.core.NamedThreadLocal;

/**
 * 动态数据源切换
 *
 * @author kun.li
 */
public final class DynamicDsHolder {


    private static final ThreadLocal<String> DYNAMIC_DS = new NamedThreadLocal<>("dynamic-ds");


    public static void pushDs(String key) {
        DYNAMIC_DS.set(key);

    }

    public static String getValue() {
        return DYNAMIC_DS.get();
    }

    public static void reset() {
        DYNAMIC_DS.remove();
    }


}
